package com.test.thread.timer;

import java.util.Date;
import java.util.TimerTask;

public class MyTimerTask extends TimerTask {

	private TaskExecutor taskExecutor;

	private static MyTimerTask instance = null;

	private MyTimerTask(TaskExecutor t) {
		this.taskExecutor = t;
	}

	public static MyTimerTask getInstance(TaskExecutor t) {
		if (instance == null) {
			instance = new MyTimerTask(t);
		}
		return instance;
	}

	@Override
	public void run() {
		System.out.println(new Date(System.currentTimeMillis())+" calling taskExecutor... ");
		taskExecutor.doLongtimeJob();
		System.out.println(new Date(System.currentTimeMillis())+" calling taskExecutor finished. ");
	}

}
